// import Home from "@/pages/Home";
// import Login from "@/pages/Login";
import Search from "@/pages/Search";
import Register from "@/pages/Register";
// const Search = () => import("@/pages/Search");
// const Register = () => import("@/pages/Register");

function Lazy(comp) {
	return () => comp;
}
export default [
	{
		path: "/",
		redirect: "/home",
	},
	{
		path: "/home",
		name: "home",
		component: Lazy(import("@/pages/Home")),
	},
	{
		path: "/login",
		name: "login",
		component: () => import("@/pages/Login"),
		// meta: {
		// 	isHidden: true,
		// },
	},
	{ path: "/search/:keyword?", name: "search", component: Search },
	{
		path: "/register",
		name: "register",
		component: Register,
		// meta: {
		// 	isHidden: true,
		// },
	},
	{
		path: "/detail/:skuId",
		name: "detail",
		component: () => import("@/pages/Detail"),
	},
	{
		path: "/addCartSuccess",
		name: "addCartSuccess",
		component: () => import("@/pages/AddCartSuccess"),
		beforeEnter:(from,to,next)=>{
			if(from.name==='detail'){
				next()
			}else{
				next('/detail')
			}
		}
	},
	{
		path: "/shopCart",
		name: "shopCart",
		component: () => import("@/pages/ShopCart"),
	},
	{
		path: "/trade",
		name: "trade",
		component: () => import("@/pages/Trade"),
		beforeEnter: (to, from, next) => {
			if(from.name==='shopCart'){
				next()
			}else{
				next('/shopCart')
			}

		}
	},
	{
		path: "/pay",
		name: "pay",
		component: () => import("@/pages/Pay"),
		beforeEnter:(to,from,next)=>{
			if(from.name==='trade'){
				next()
			}else{
				next('/shopCart')
			}
		}
	},
	{
		path: "/paySuccess",
		name: "paySuccess",
		component: () => import("@/pages/PaySuccess"),
		beforeEnter:(to,from,next)=>{
			if(from.name==='pay'){
				next()
			}else{
				next('/shopCart')
			}
		}
	},
	{
		path: "/center",
		// name: "center",
		component: () => import("@/pages/Center"),
		redirect:'/center/myOrder',
		children: [
			{
				path: "myOrder",
				name: "myOrder",
				component: () => import("@/pages/Center/components/MyOrder"),
			},
			{
				path: "teamOrder",
				name: "teamOrder",
				component: () => import("@/pages/Center/components/TeamOrder"),
			},
		],
	},
];
